package assess

import (
	"gitee.com/g-qs/gin-vue-admin/server/global"
	"gitee.com/g-qs/gin-vue-admin/server/model/assess"
)

type EfficacyService struct{}

// GetEfficacyList 获取功效列表
func (efficacyService *EfficacyService) GetEfficacyList() (efficacy []assess.Efficacy, err error) {
	err = global.GVA_DB.Find(&efficacy).Error
	return
}

// GetEfficacyTagByUid 获取用户功效标签
func (efficacyService *EfficacyService) GetEfficacyTagByUid(id uint) (uet assess.UserEfficacyTag, err error) {
	err = global.GVA_DB.Where("id = ?", id).First(&uet).Error
	return uet, err
}

// CreateUserEfficacyTag 创建用户功效标签
func (efficacyService *EfficacyService) CreateUserEfficacyTag(uet *assess.UserEfficacyTag) (err error) {
	err = global.GVA_DB.Create(uet).Error
	return err
}

// UpdateUserEfficacyTag 更新用户功效标签
func (efficacyService *EfficacyService) UpdateUserEfficacyTag(id uint, eids string) (err error) {
	err = global.GVA_DB.Model(&assess.UserEfficacyTag{}).Where("id = ?", id).Update("e_ids", eids).Error
	return err
}
